home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Gekikoh Dennoh Club 1
/
Gekikoh Dennoh Club Vol. 1 (Japan).7z
/
Gekikoh Dennoh Club Vol. 1 (Japan) (Track 1).bin
/
kowin
/
archive
/
apl
/
pedp.lzh
/
ped.c
< prev
next >
Wrap
C/C++ Source or Header
|
1996-01-13
|
6KB
|
226 lines
#include <stdio.h>
#include "wlib.h"
#include "parts.h"
#include "winop.h"
int WindowHeapSize = 4 * 1024 ;
/*
proto get.c > temp
*/
int RequestExec( WindowID, EventInfo* );
extern PatternOpen( WindowID, char*, int, int, int, Sheet* );
static int inputflag, typeflag = 1 ;
static DrawBuf drawbuf[15] ;
static char FileName[98], Xchar[10], Ychar[10] ;
void WindowMain( argc, argv )
int argc ;
char *argv[] ;
{
int x = 150, y = 120, dmy ;
argc = AnalizeArgs( argc, argv, &x, &y, &dmy, &dmy );
if( argc >= 2 )
strcpy( FileName, *++argv );
WindowTitleOpen( x, y, 200, 120, NULL, "Pattern Editor +", Close|Push, RequestExec );
}
SrcSelect( wp, n )
WindowID wp;
{
if ( n == 1 || n == 2 ){
typeflag = n ;
n = AttrReverse * ( n == 2 ) + 1 ;
DrawSetSymbol( drawbuf+9, 60, 90+4, "Source", n, 16 );
DrawSetSymbol( drawbuf+10, 120, 90+4, "Include", n ^ AttrReverse, 16 );
WindowDraw( wp, drawbuf+9, 2 );
}
}
int RequestExec( wp, info )
WindowID wp ;
EventInfo *info ;
{
int n, i, x, y ;
DrawBuf buf[10], *bufp ;
char **p ;
Sheet *sp ;
static InputClass input[3] ;
switch( info->option )
{
case EventOpen :
InputSet( input, 100, 36, FileName, 88, AttrDefault, 12 );
InputSetCursorVisible( NULL, input, FALSE );
InputSet( input+1, 100, 54, Xchar, 5, AttrDefault, 16 );
InputSetCursorVisible( NULL, input+1, FALSE );
InputSet( input+2, 100, 74, Ychar, 5, AttrDefault, 16 );
InputSetCursorVisible( NULL, input+2, FALSE );
/* strcpy( FileName, "" );*/
strcpy( Xchar, "16" );
strcpy( Ychar, "16" );
DrawSetClear( drawbuf, 1 );
x = ( 200 - sizeof( "Edit Pattern Data" )*8 ) / 2 ;
DrawSetSymbol( drawbuf+1, x, 5+4, "Edit Pattern Data",
AttrDefault+AttrHighLight, 16 );
DrawSetSymbol( drawbuf+2, 8, 30+4, "File Name", AttrDefault, 16 );
DrawSetSymbol( drawbuf+3, 8, 50+4, "X size", AttrDefault, 16 );
DrawSetSymbol( drawbuf+4, 8, 70+4, "Y size", AttrDefault, 16 );
DrawSetLine( drawbuf+5, 100, 34+17, 180, 34+17, 0, OptionLine );
DrawSetLine( drawbuf+6, 100, 54+17, 140, 54+17, 0, OptionLine );
DrawSetLine( drawbuf+7, 100, 74+17, 140, 74+17, 0, OptionLine );
DrawSetSymbol( drawbuf+8, 8, 90+4, "Type", AttrDefault, 16 );
DrawSetSymbol( drawbuf+9, 60, 90+4, "Source", 1, 16 );
DrawSetSymbol( drawbuf+10, 120, 90+4, "Include", AttrDefault, 16 );
WindowRedraw( wp );
WindowSetEventAttr( wp, EventAttrDefault|EventMouseMoveON|EventUserON );
break ;
case EventRedraw :
WindowDraw( wp, drawbuf, 11 );
for( i = 0 ; i < 3 ; ++i )
{
n = InputSetDraw( buf, input+i );
WindowDraw( wp, buf, n );
}
break ;
case EventClose :
WindowClose( wp );
WindowConnectionClose();
return( TRUE );
case EventMouseEnter :
n = InputSetCursorVisible( buf, input+inputflag, TRUE );
WindowDraw( wp, buf, n );
break ;
case EventMouseOut :
n = InputSetCursorVisible( buf, input+inputflag, FALSE );
WindowDraw( wp, buf, n );
break ;
case EventMouseMove :
case EventMouseSwitch :
if ( info->LeftON )
{
if ( 94 <= info->y && info->y < 110 )
{
n = info->x / 60 ;
SrcSelect( wp, n );
}
for( i = 0 ; i < 3 ; ++i )
{
if ( i != inputflag &&
ClipInner( (ClipClass*)(input+i), info->x, info->y ) )
{
bufp = buf ;
bufp += InputSetCursorVisible( bufp, input+inputflag, FALSE );
inputflag = i ;
bufp += InputSetCursorVisible( bufp, input+inputflag, TRUE );
WindowDraw( wp, buf, bufp - buf );
}
}
if( ClipInner( (ClipClass*)(input),
info->x, info->y ) ){
UserSendOperation( wp, info,
UserString, FileName );
return TRUE;
}
}
return( DefaultMouseOperation( wp, info ) );
break ;
case EventKey :
bufp = buf ;
switch( info->KeyCode )
{
case FuncKeyF(1):
SrcSelect( wp, 1 );
return TRUE;
case FuncKeyF(2):
SrcSelect( wp, 2 );
return TRUE;
case FuncKeyUp :
case 0x10: /* CTRL-P */
case 5 : /* CTRL-E */
if ( inputflag > 0 )
{
bufp += InputSetCursorVisible( bufp, input+inputflag, FALSE );
inputflag -- ;
bufp += InputSetCursorVisible( bufp, input+inputflag, TRUE );
}
break ;
case FuncKeyDown :
case 0xe: /* CTRL-N */
case 0x18 : /* CTRL-X */
if ( inputflag < 2 )
{
bufp += InputSetCursorVisible( bufp, input+inputflag, FALSE );
inputflag ++ ;
bufp += InputSetCursorVisible( bufp, input+inputflag, TRUE );
}
break ;
case 13 : /* ENTER */
x = atoi( Xchar );
y = atoi( Ychar );
if ( x > 0 && y > 0 && strlen( FileName ) > 0 )
{
if ( PatternOpen( wp, FileName, x, y, typeflag, NULL ) )
{
WindowSetAttr( wp, WindowAttrInvisible );
}
else
{
WindowClose( wp );
WindowConnectionClose();
return( TRUE );
}
}
break ;
default :
bufp += InputKey( bufp, input+inputflag, info->KeyCode, info->ShiftStat );
}
if ( bufp > buf )
WindowDraw( wp, buf, bufp - buf );
break ;
case EventUser :
sp = NULL ;
switch( info->ComData )
{
case UserPaste :
case UserString :
strcpy( FileName, info->ComBuffer );
break ;
case UserStrings :
p = info->ComBuffer ;
if ( p[0] == NULL )
return( TRUE );
strcpy( FileName, p[0] );
break ;
case UserSheet :
if ( strlen( FileName ) == 0 )
strcpy( FileName, "untitled" );
sp = info->ComBuffer ;
break ;
default :
return( FALSE );
}
if ( PatternOpen( wp, FileName, 0, 0, typeflag, sp ) )
{
WindowSetAttr( wp, WindowAttrInvisible );
}
else
{
WindowClose( wp );
WindowConnectionClose();
return( TRUE );
}
break ;
}
return( TRUE );
}